package com.xinxing.learning.crud.batch.transactional;

import java.util.List;
import java.util.concurrent.CountDownLatch;

public abstract class BatchInsertThread<T> implements Runnable {
    private List<T> list;
    private CountDownLatch begin, end;

    public BatchInsertThread(List<T> list, CountDownLatch begin, CountDownLatch end) {
        this.list = list;
        this.begin = begin;
        this.end = end;
    }

    @Override
    public void run() {
        try {
            begin.await();
            method(list);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

    }

    public abstract void method(List<T> list);
}
